import axios from 'axios';

axios.defaults.withCredentials = true;
axios.defaults.baseURL =
  process.env.NODE_ENV === 'production'
    ? 'https://testapi.scloudint.com'
    : 'https://api.scloudint.com';
// axios.defaults.baseURL = '/api';
//
// Add a response interceptor
axios.interceptors.response.use(
  function (response) {
    if (response.data.code == 2006) {
      window.location.href = 'https://testems.scloudint.com';
      // window.location.href = 'https://ems.scloudint.com';
    }
    return response;
  },
  function (error) {
    return Promise.reject(error);
  },
);
export default axios;
